//
// Created by 谢哲 on 2021/5/9.
//

#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main() {
    string s;
    cin >> s;

    stack<pair<int, int>> start_pos;
    string result;
    auto len = s.length();
    for (size_t i=0; i<len; ++i) {
        if (s[i]=='[') {
            int cur_num = 0;
            size_t j=i+1;
            for (j=i+1; s[j]>='0'&&s[j]<='9'; ++j) {
                cur_num = cur_num * 10 + int(s[j] - '0');
            }
            i = j-1;
            start_pos.push(make_pair(result.length(), cur_num));
        }
        else if (s[i]==']') {
            auto stack_top = start_pos.top();
            string cur_s = result.substr(stack_top.first);
            start_pos.pop();
            for (auto remain=stack_top.second;remain>1;--remain) {
                result += cur_s;
            }
        }
        else {
            result += s[i];
        }
    }

    cout << result;

    return 0;
}